home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / ArchiveUtils / DATer / Source / Controller.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  124 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "Controller.h"
  5. #import <appkit/Application.h>
  6. #import <appkit/Listener.h>
  7. #import <appkit/Pasteboard.h>
  8. #import <appkit/View.h>
  9. #import <appkit/Window.h>
  10. #import <appkit/TextField.h>
  11. #import <appkit/ScrollView.h>
  12. #import <appkit/Scroller.h>
  13. #import <appkit/Form.h>
  14. #import <appkit/Text.h>
  15. #import <streams/streams.h>
  16. #import <strings.h>
  17.  
  18. @implementation Controller
  19.  
  20. - appDidInit:sender
  21. {
  22.     [[NXApp appListener] setServicesDelegate:self];
  23.     return self;    
  24. }
  25.  
  26. //this probably should be broken up into two funcs.  One for an RTF message and one for
  27. //an ASCII message.  Oh well, it works...
  28.  
  29. - servicesMessage:(id)pasteboard
  30.     userData:(const char *)sortArgs
  31.     error:(char **)errorMessage
  32. {
  33.    int length, currentType;
  34.     const char *data;
  35.     const char *const *ptypes;
  36.     NXStream    *stream;
  37.     
  38.        
  39.     ptypes=[pasteboard types];
  40.     
  41.    //Look for RTF first...
  42.        for (currentType=0; ptypes[currentType] ; currentType++ ){
  43.         if (!strcmp(ptypes[currentType],NXRTFPboardType)){
  44.             [pasteboard readType:ptypes[currentType] data:&data length:&length];
  45.             stream = NXOpenMemory(data, length, NX_READONLY);
  46.             [[contentField docView] readRichText:stream];
  47.             NXCloseMemory(stream, NX_FREEBUFFER);
  48.             return self;
  49.         
  50.         }
  51.     }
  52.        for (currentType=0; ptypes[currentType] ; currentType++ ){
  53.         if (!strcmp(ptypes[currentType],NXAsciiPboardType))  {
  54.             [pasteboard readType:ptypes[currentType] data:&data length:&length];
  55.             stream = NXOpenMemory(data, length, NX_READONLY);
  56.             [[contentField docView] readText:stream];
  57.             NXCloseMemory(stream, NX_FREEBUFFER);
  58.             return self;
  59.             
  60.         }
  61.      }
  62.     return self;    //should never be reached....
  63. }
  64.  
  65. - setOutputTitleField:anObject
  66.  
  67. {
  68.     outputTitleField = anObject;
  69.     [outputTitleField setDrawRotation:(NXCoord)90.0];
  70.     [[outputTitleField setVertScrollerRequired:NO] display];
  71.     
  72.     return self;
  73. }
  74.  
  75. - setContentField:anObject
  76.  
  77. {
  78.     contentField = anObject;
  79.     [[contentField setVertScrollerRequired:NO] display];
  80.     return self;
  81. }
  82.  
  83. - doPrint:sender
  84.  
  85. {
  86.     [group printPSCode:self];
  87.     return self;
  88. }
  89.  
  90. - copyText:sender
  91.  
  92. {    NXStream    *stream;
  93.     char            *buffer;
  94.     int            length, maxlength;
  95.     
  96.     stream = NXOpenMemory(NULL, 0, NX_WRITEONLY);
  97.     [[inputTitleField docView] writeRichText:stream];
  98.     NXGetMemoryBuffer(stream, &buffer, &length, &maxlength);
  99.     NXCloseMemory(stream, NX_SAVEBUFFER);
  100.  
  101.     stream = NXOpenMemory(buffer, length, NX_READONLY);
  102.     [[outputTitleField docView] readRichText:stream];
  103.     NXCloseMemory(stream, NX_FREEBUFFER);
  104.  
  105.  
  106.     return self;
  107. }
  108.  
  109. - doScale:sender
  110.  
  111. {    NXCoord    newScale;
  112.     id cView;
  113.     NXRect    rect;
  114.     
  115.     cView = [window contentView];
  116.     newScale = [scaleForm floatValueAt:0];
  117.     [cView getFrame:&rect];
  118.     [window sizeWindow :rect.size.width*newScale :rect.size.height*newScale];
  119.     [cView scale:newScale :newScale];
  120.     [window display];
  121.     return self;
  122. }
  123.  
  124. @end